<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%--
  Created by IntelliJ IDEA.
  User: 18134216985
  Date: 2024-04-11
  Time: 16:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="/webjars/layui/2.6.8/layui.js"></script>
    <link rel="stylesheet" href="/webjars/layui/2.6.8/css/layui.css">
</head>
<body>
<%--条件查询--%>
<div class="layui-collapse">
    <div class="layui-colla-item">

        <h2 class="layui-colla-title">查询条件</h2>
        <div class="layui-colla-content layui-show">
            <div class="layui-form"  id="searchForm" lay-filter="searchForm">
                <div class="layui-inline">
                    <input name="repairsType" class="layui-input" placeholder="维修类型">
                </div>
                <div class="layui-inline">
                    <input name="position" class="layui-input" placeholder="维修位置">
                </div>
                <div class="layui-inline">
                    <input type="text" name="repairpeople" class="layui-input" placeholder="报修人">

                </div>
                <div class="layui-inline">
                    <select name="plotid" >
                        <option value="0">请选择小区</option>
                    </select>

                </div>
                <div class="layui-inline">
                    <select name="employeeid" >
                        <option value="0">请选择员工</option>
                    </select>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn" onclick="search()" >查询</button>
                </div>
            </div>
        </div>
    </div>
</div>
<table class="layui-hide" id="ID-table-demo-data" lay-filter="repairingTable"></table>
<script>
    let $=layui.$;
    let table = layui.table;
    let laydate = layui.laydate;
    layui.use(["table","laydate"],function (){
        laydate.render({
            elem:"[name=hopetime]"
            ,format : "yyyy/MM/dd"
        });
        table.render({
            id:'recording',
            elem:"#ID-table-demo-data",
            url:"/Repairs/selectAllRepairing",
            page:true,
            cols:[[
                {field:'number',align: 'center',type:'numbers',title:"编号"},
                {align: 'center',field:'id',hide:true,title:'编号'},
                {align: 'center',field: 'position',title: '报修位置'},
                {align: 'center',field: 'repairtype',title: '报修描述'},
                {align: 'center',field: 'repairpeople',title: '报修人'},
                {align: 'center',field: 'phone',title: '联系电话'},
                {align: 'center',field: 'plotname',title: '小区名称',templet(d) {
                        return d.plot==null?"-":d.plot.plotname
                    }},
                {align: 'center',field: 'hopetime',title: '预约时间'},
                {align: 'center',field: 'img',title: '照片',templet(d) {
                        return  d.img==null?"-":"<img src='/"+d.img+"' width='50px'/>";
                    }},
                {align: 'center',field: 'money',title: '价格'},
                {align: 'center',field: 'istype',title: '报修类型',templet(d) {
                        return d.istype==1?"居家维修":"公共维修";
                    }},
                {align: 'center',field: 'repstateid',title: '报修状态',templet(d){
                        return d.repairstate == null ? "-" : d.repairstate.statename;
                    }},
                {align: 'center',title: '员工',templet(d) {
                        return d.user == null ? "-" : d.user.username;
                    }},
            ]]
        })
    })
    //点击查询
    function search(){
        var search=layui.form.val('searchForm');
        console.log(search)
        layui.table.reload('recording', {
            page: {
                curr:1
            },
            where: search
        });
    }
    //渲染员工的下拉列表、
    $.get("/Users/selectAllUserByPortId").then(({data})=>{
        $(data).each(function (i,e){
            let option =$("<option value='"+e.id+"'>"+e.username+"</option>")
            $("[name=employeeid]").append(option);
        })
        layui.form.render('select');
    })
    //渲染小区的下拉列表、
    $.get("/property/plot/show").then(({data})=>{
        $(data).each(function (i,e){
            let option =$("<option value='"+e.id+"'>"+e.plotname+"</option>")
            $("[name=plotid]").append(option);
        })
        layui.form.render('select');
    })
</script>
</body>
</html>
